//
//  OrderDeliveryItemView.m
//  JiaoX
//
//  Created by yinqy on 15/2/3.
//  Copyright (c) 2015年 北京娇羞科技有限公司. All rights reserved.
//

#import "OrderDeliveryItemView.h"

@interface OrderDeliveryItemView()
{
    UIImageView *_leftLine;
    UIImageView *_leftImage;
    UILabel *_descLabel;
    UILabel *_timeLabel;
}

@end
@implementation OrderDeliveryItemView


- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        _leftLine = [[UIImageView alloc]init];
        [_leftLine setBackgroundColor:JXColor(230, 230, 230)];
        [self addSubview:_leftLine];
        
        _leftImage = [[UIImageView alloc]init];
        [self addSubview:_leftImage];
        
        _descLabel = [[UILabel alloc]init];
        [_descLabel setFont:[UIFont systemFontOfSize:DESC_FONT_SIZE]];
        [self addSubview:_descLabel];
        
        _timeLabel = [[UILabel alloc]init];
        [_timeLabel setFont:[UIFont systemFontOfSize:TIME_FONT_SIZE]];
        [self addSubview:_timeLabel];
    }
    return self;
}

-(void)setIndexPath:(NSIndexPath *)indexPath{
    if (indexPath.row==0) {
        [_descLabel setTextColor:JXThemeColor];
        [_timeLabel setTextColor:JXThemeColor];
        [_leftImage setImage:[UIImage imageNamed:@"ic_order_delivery_fly"]];
    }else{
        [_descLabel setTextColor:JXColor(77, 77, 77)];
        [_timeLabel setTextColor:JXColor(128, 128, 128)];
        [_leftImage setImage:[UIImage imageNamed:@"ic_order_delivery_point"]];
    }
}

-(void)setDeliveryItemFrame:(OrderDeliveryItemFrame *)deliveryItemFrame{
    _deliveryItemFrame = deliveryItemFrame;
    self.frame = deliveryItemFrame.frame;
    
    [_leftLine setFrame:deliveryItemFrame.leftLineFrame];
    [_leftImage setFrame:deliveryItemFrame.leftImageFrame];
    
    [_descLabel setText:deliveryItemFrame.deliverItem.context];
    [_descLabel setFrame:deliveryItemFrame.rightDescFrame];
    
    [_timeLabel setText:deliveryItemFrame.deliverItem.time];
    [_timeLabel setFrame:deliveryItemFrame.rightTimeFrame];
}

@end
